; $Id: syntax.scm,v 1.3 2000/05/23 20:13:58 jim Exp $
;- syntax.scm ------------------------------------------------------
; Find the syntax of an ACIS Scheme extension command
; (syntax 'solid:skin-faces )
;
;returns
;"   (SOLID:SKIN-FACES face0 face1 [arc_length]"
;"       [minimize_twist] [align_directions] [simplify])"
;""
;"Arg Types:"
;"   arc_length                     boolean"
;"   align_directions               boolean"
;"   face0                             face"
;"   face1                             face"
;"   minimize_twist                 boolean"
;"   simplify                       boolean"
;""
;------------------------------------------------------------------
; The Syntax command needs two files syntax.txt and syntax_index.txt
; These file need to be updated for every release
; They are generated by the following ksh commands
;
; find pool -name "[a-z]*_scm.cxx" > scm_cxx.lst
; find pool -name "scm_[a-z]*.cxx" >> scm_cxx.lst
; for file in `cat scm_cxx.lst`
; do
; syntax $file
; done
;
; syntax_index
;
; The following is the syntax command.
; cat $1 | awk '/\/\/[ ]*Syntax:[ ]*/, /\/\/[ ]*Errors:[ ]*/' | grep -v Errors | 
; sed '1,$s/\/\/[	]//g' | sed '1,$s/\/\///g' | sed '1,$s/	/    /g' >> syntax.dat
;
; The following is the syntax_index command.
; cat syntax.dat | awk 'BEGIN {count=0;} {count++;} /^Syntax:/ {getline; count++; print $1 " "   count}' |
; sed '1,$s/(//' | sed '1,$s/)//' > syntax_index.dat ; echo "end-of-file `cat syntax.dat |
; wc -l`" >> syntax_index.dat


; load support procedures
(load "synread.scm")
;
; Scheme Syntax procedure
;
(define syntax (lambda (command_name )
                 (begin
                   (if (symbol? command_name)
                       (set! command_name (symbol->string command_name))
                       (if (not (string? command_name))
                           (error 'syntax "string or symbol expected")))
                   (define out_list (list))
                   (define start_end (list))
                   ; Open index file
                   (define syntax_index_file (find-file "syntax_index.dat"))
                   (if (not (string=? syntax_index_file "") )
                       (begin
                         (define dataport (open-input-file syntax_index_file))
                         ; Find the index of the comand
                         (define start_end (find-name dataport command_name))
                         ; close data file
                         (close-input-port dataport )
                         ;Print the syntax data for the given command
                         (if (not (null? start_end) )
                             (begin
                               (define syntax_file (find-file "syntax.dat"))
                               (if (not (string=? syntax_file "") )
                                   (syntax-print syntax_file start_end)
                                   (error 'syntax "syntax.dat file not found. Try adding the Scheme examples directory to LOAD-PATH")
                                   )
                               )
                             (error 'syntax "Command not found.")
                             )
                         )
                       (error 'syntax "syntax_index.dat file not found. Try adding the Scheme examples directory to LOAD-PATH")
                       )
                   )
                 ))
